home *** CD-ROM | disk | FTP | other *** search
/ Logiciels PC Special 3 / Logiciel PC - Hors-Serie 3.iso / Logs / micros / ql / outils / qltoolsq / source / qltools.h < prev    next >
C/C++ Source or Header  |  1998-05-18  |  4KB  |  198 lines

  1. #ifdef __unix__
  2. # include <sys/time.h>
  3. # include <unistd.h>
  4. #else
  5.    typedef unsigned char unchar;
  6.    typedef unsigned short ushort;
  7.    typedef unsigned long ulong;
  8. #  define inline
  9. # if defined (__VMS) || defined(__ALPHA) || defined(VMS)
  10. # ifndef __DECC
  11. #  error "You need a real 'C' compiler"
  12. # endif
  13. # include <sys/time.h>
  14. # include <unixio.h>
  15. # include <fcntl.h>
  16. # define FDNAME "diskimage"
  17. # ifdef __ALPHA
  18. #  define OSNAME "Alpha-AXP"
  19. # else
  20. #  define OSNAME "VAX-VMS"
  21. # endif
  22. # else
  23. #  include <conio.h>
  24. #  include <io.h>
  25. #  include <malloc.h>
  26. #  include <time.h>
  27. #  endif
  28. #endif
  29.  
  30. #ifdef __NT__
  31. #include <windows.h>
  32. #define OSNAME "Windows NT"
  33. #define FDNAME "\\\\.\\a:"
  34. #define DOS_LIKE
  35. #endif
  36.  
  37. #ifdef __OS2__
  38. #include <os2.h>
  39. typedef HFILE HANDLE;
  40. #define OSNAME "OS/2"
  41. #define FDNAME "a:"
  42. #define DOS_LIKE
  43. #else
  44. # ifndef __NT__
  45.  typedef int HANDLE;
  46.  #endif
  47. #endif
  48.  
  49. #ifdef __unix__
  50. # ifdef __linux__
  51. #  define OSNAME "Linux"
  52. # else
  53. #  ifdef __DJGPP__
  54. #   define OSNAME "DJGPP"
  55. #  else
  56. #   define OSNAME "Unix"
  57. #  endif
  58. # endif
  59. # define FDNAME "/dev/fd0H720"
  60. #else
  61. # ifndef OSNAME
  62. #  define OSNAME "MSDOS"
  63. #  define DOS_LIKE
  64. # endif
  65. # ifndef FDNAME
  66. #  define FDNAME "a:"
  67. # endif
  68. #endif
  69.  
  70. #define TIME_DIFF    283996800
  71. #define VERSION     "2.7q, " __DATE__
  72.  
  73. /* Maximum allocation block (normally 3) */
  74. #define MAXALB          6
  75.  
  76. /* Maximum number of sectors (norm. 1440) */
  77. #define MAXSECT         2880
  78.  
  79. #if defined(__linux__) || defined(__DJGPP__)    /* jv */
  80. #define PACKED  __attribute__ ((packed))
  81. #else
  82. #define PACKED
  83. #endif
  84.  
  85. #define GSSIZE 512
  86. #define DIRSBLK 8
  87.  
  88. typedef struct
  89. {
  90.     long d_length;        /* file length */
  91.     unsigned char d_access;    /* file access type */
  92.     unsigned char d_type;    /* file type */
  93.     long d_datalen PACKED;    /* data length */
  94.     long d_reserved PACKED;    /* Unused */
  95.     short d_szname;        /* size of name */
  96.     char d_name[36];        /* name area */
  97.     long d_update PACKED;    /* last update */
  98.     short d_version;
  99.     short d_fileno;
  100.     long d_backup;
  101. } QLDIR;
  102.  
  103. #ifdef __DJGPP__
  104.    typedef unsigned char unchar;
  105.    typedef unsigned short ushort;
  106.    typedef unsigned long ulong;
  107. #endif
  108.  
  109. typedef struct
  110. {
  111.     char q5a_id[4];
  112.     unchar q5a_mnam[10];
  113.     ushort q5a_rand;
  114.     ulong q5a_mupd;
  115.     ushort q5a_free;
  116.     ushort q5a_good;
  117.     ushort q5a_totl;
  118.     ushort q5a_strk;
  119.     ushort q5a_scyl;
  120.     ushort q5a_trak;
  121.     ushort q5a_allc;
  122.     ushort q5a_eodbl;
  123.     ushort q5a_eodby;
  124.     ushort q5a_soff;
  125.     unchar q5a_lgph[18];
  126.     unchar q5a_phlg[18];
  127.     unchar q5a_spr0[20];
  128.     unchar map[1];
  129. } BLOCK0;
  130.  
  131. typedef struct __sdl__
  132. {
  133.     struct __sdl__ *next;
  134.     ulong flen;
  135.     ushort fileno;
  136.     short szname;
  137.     char name[36];
  138. } SDL;
  139.  
  140. typedef struct
  141. {
  142.     short nfiles;
  143.     short rflag;
  144.     short freed;
  145.     short indir;
  146. } COUNT_S;
  147.  
  148. typedef struct
  149. {
  150.     QLDIR *nde;
  151.     int *nptr;
  152.     short fnew;
  153. } FSBLK;
  154.  
  155.  
  156. extern int gsides, gtracks, gsectors, goffset, allocblock, gclusters, gspcyl;
  157. extern BLOCK0 *b0;
  158.  
  159. /* ----------- logical to physical translation macros -------------------- */
  160.  
  161. #define LTP_TRACK(_sect_)   ((_sect_)/gspcyl)
  162. #define LTP_SIDE(_sect_)    (b0->q5a_lgph[(_sect_)%gspcyl] &0x80 ? 1 : 0)
  163. #define LTP_SCT(_sect_) \
  164.        (((0x7f& b0->q5a_lgph[(_sect_)%gspcyl])+ \
  165.        goffset*LTP_TRACK(_sect_)) % gsectors)
  166. #define LTP_SECT(_sect_)    (LTP_SCT(_sect_)+1)
  167.  
  168. #define LTP(_sect_)   ((long) 512L*(long)(LTP_TRACK(_sect_)*gspcyl+ \
  169.                        LTP_SIDE(_sect_)*gsectors+LTP_SCT(_sect_)))
  170.  
  171. #ifndef min
  172. # define min(a,b) (a<b ? a : b)
  173. #endif
  174.  
  175. HANDLE OpenQLDevice (char *device, int mode);
  176. int ReadQLSector (HANDLE fd, void *buf, int sector);
  177. int WriteQLSector (HANDLE fd, void *buf, int sector);
  178. void CloseQLDevice (HANDLE);
  179. time_t GetTimeZone (void);
  180. void ZeroSomeSectors(HANDLE fd, short);
  181.  
  182. #if defined (__linux__) || defined (VMS)
  183. int getch(void);
  184. int strnicmp (const char *s, const char *d, int n);
  185. int stricmp (const char *s, const char *d);
  186. # ifndef O_BINARY
  187. # define O_BINARY 0
  188. # endif
  189. #else
  190. extern void usage(char *);
  191. #endif
  192.  
  193. #define QLDIRSTRING "qltools:type255\012"
  194. #ifdef VMS
  195. char *strdup(const char *);
  196. #endif
  197.  
  198.